package com.guhappy.interceptor;

import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class AuditInterceptor extends AbstractInterceptor{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Date dateTime;
	
	private String modifiedby;
	
	private String action;
	
	private String field;
	
	private String input;
	private static Map<String, Set> policiesMap = new HashMap<String, Set>();
	private static final String AuthenticationRequestResult="authentication_required";
	private static final String Donothavevalidsession="session_required";
	
	protected Logger log = Logger.getLogger(getClass());
	
	public void init() {
    }

	@Override
    public String intercept(ActionInvocation ai) throws SQLException,Exception  {
		HttpServletRequest request = ServletActionContext.getRequest();
		Object action = ai.getAction();
		String method = ai.getProxy().getMethod();
       
	       // call action--do business logic
	       ai.invoke();
	       
	       // after struts action now we do the log stuff
	      
	       return Action.SUCCESS;

   }
}